package com.listeningframework.boot.autoconfigure.template.freemarker.templates;

import javax.annotation.PostConstruct;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.stereotype.Component;

import com.listeningframework.boot.autoconfigure.template.freemarker.ListeningFreeMarkerProperties;
import com.listeningframework.boot.autoconfigure.template.freemarker.overrides.ListeningFreemarkerSimpleHash;
import com.listeningframework.boot.autoconfigure.template.freemarker.templates.standard.MetaTag;
import com.listeningframework.boot.autoconfigure.template.freemarker.templates.standard.OssCssTag;
import com.listeningframework.boot.autoconfigure.template.freemarker.templates.standard.OssImageTag;
import com.listeningframework.boot.autoconfigure.template.freemarker.templates.standard.OssJsTag;
import com.listeningframework.boot.autoconfigure.template.freemarker.templates.standard.OssUrlTag;

/**
 * 自定义标签汇总
 * 
 * @author lixining
 * @version $Id: ListeningTags.java, v 0.1 2014年7月8日 下午5:20:16 lixining Exp $
 */
@Component
@ConditionalOnClass({ freemarker.template.Configuration.class })
public class ListeningStandardFreemarkerSimpleHash extends ListeningFreemarkerSimpleHash {

    /**  */
    private static final long             serialVersionUID = 316766354957047446L;

    private static final String           VARIABLE         = "listening";

    @Autowired
    private ListeningFreeMarkerProperties listeningProperties;

    @Override
    public String getVariable() {
        return VARIABLE;
    }

    @Override
    @PostConstruct
    public void execute() {
        addTag(OssCssTag.class, "ossCss", listeningProperties);
        addTag(OssJsTag.class, "ossJs", listeningProperties);
        addTag(OssImageTag.class, "ossImage", listeningProperties);
        addTag(OssUrlTag.class, "ossUrl", listeningProperties);
        // Standard tags
        addTag(MetaTag.class, "meta", listeningProperties);
    }

}
